package com.woniu.publishe;

import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Classname TopicPublisher
 * @Description TODO
 * @Date 2025/7/22 14:21
 * @Created by pc
 */
@Component
public class TopicPublisher implements RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnsCallback {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void send(Object msg){
        rabbitTemplate.convertAndSend("orderExchange","order",msg);
    }

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        System.out.println("消息补偿");
    }

    @Override
    public void returnedMessage(ReturnedMessage returned) {
        System.out.println("消息补偿");
    }
}
